package org.micropayment.consumer.oauth.service;

import org.micropayment.model.ProviderResource;
import org.micropayment.model.service.ProviderResourceDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth.consumer.ProtectedResourceDetails;
import org.springframework.security.oauth.consumer.ProtectedResourceDetailsService;
import org.springframework.stereotype.Service;

/**
 *
 * @author jj
 */
@Service("protectedResourceDetails")
public class MicropaymentProtectedResourceDetailsService 
        implements ProtectedResourceDetailsService{

    @Autowired ProviderResourceDAO providerDao;

    public ProtectedResourceDetails loadProtectedResourceDetailsById(String id) 
            throws IllegalArgumentException {
        ProviderResource provider = providerDao.findById(id);
        return new MicropaymentConsumerResourceDetails(provider);
    }

}
